﻿using System.Security.Cryptography;
using System.Text;

namespace minichatclient.Utils;

public static class Md5Helper{
    public static string GetMd5(byte[] data){
        try {
            MD5 md5 = new MD5CryptoServiceProvider();
            var retVal = md5.ComputeHash(data);
            StringBuilder sb = new ();
            for (var i = 0; i < retVal.Length; i++) {
                sb.Append(retVal[i].ToString("x2"));
            }
            return sb.ToString();
        }
        catch (System.Exception ex) {
            throw new System.Exception("GetMD5Hash() fail,error:" + ex.Message);
        }
    }
}